﻿namespace JavaScript8000.MagicBox
{
    using System;

    /// <summary>
    /// Represent value of virtual variables.
    /// </summary>
    public class VVarValue : ICloneable
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="VVarValue"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        public VVarValue(VVarValue value)
        {
            this.Type = value.Type;
            this.Value = value.Value;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="VVarValue"/> class.
        /// </summary>
        public VVarValue()
        {
        }

        #endregion

        #region Enums

        /// <summary>
        /// Represent types of virtual variables.
        /// </summary>
        [Flags]
        public enum VVarType
        {
            /// <summary>
            /// Unknown type.
            /// </summary>
            Unknown = 0,

            /// <summary>
            /// Function type.
            /// </summary>
            Function = 1,

            /// <summary>
            /// Array type.
            /// </summary>
            Array = 2,

            /// <summary>
            /// Object type.
            /// </summary>
            Object = 4,

            /// <summary>
            /// Decimal type.
            /// </summary>
            Decimal = 8,

            /// <summary>
            /// String type.
            /// </summary>
            String = 16,

            /// <summary>
            /// Bool type.
            /// </summary>
            Bool = 32,
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the type of value.
        /// </summary>
        /// <value>
        /// The type.
        /// </value>
        public VVarType Type { get; set; }

        /// <summary>
        /// Gets or sets Value.
        /// </summary>
        public object Value { get; set; }

        #endregion

        #region Public Methods

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            return new VVarValue { Type = this.Type, Value = this.Value };
        }

        #endregion
    }
}